package net.hn.hnms.biz.gasext.dws.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import net.hn.hnms.biz.gasext.dws.domain.fineData.DwmcEntity;
import net.hn.hnms.biz.gasext.dws.domain.fineData.InsertShiftManage1Po;
import net.hn.hnms.biz.gasext.dws.domain.fineData.ShiftManagementPo;
import net.hn.hnms.biz.gasext.dws.mapper.finedata.DwmcEntityMapper;
import net.hn.hnms.biz.gasext.dws.mapper.finedata.InsertShiftManage1Mapper;
import net.hn.hnms.biz.gasext.dws.mapper.finedata.ShiftManagementMapper;
import net.hn.hnms.biz.gasext.dws.service.FineDataService;
import net.hn.hnms.sys.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 帆软接口实现类
 */
@Service
@DS(value = "fineData")
public class FineDataServiceImpl implements FineDataService {

    //获取帆软编码表
    @Resource
    private DwmcEntityMapper fineDataCodeMapper;


    /**
     * 获取带值班班次列表
     */
    @Resource
    private ShiftManagementMapper shiftManagementMapper;

    /**
     * 班次记录表
     */
    @Resource
    private InsertShiftManage1Mapper insertShiftManage1Mapper;

    /**
     *
     * 获取帆软编码表
     * @param mineCode
     * @return
     */

    @Override
    public List<DwmcEntity> getFineListByCode(String mineCode) {
        List<DwmcEntity> dwmcEntities = fineDataCodeMapper.selectList(new LambdaQueryWrapper<DwmcEntity>().eq(StringUtils.isNotBlank(mineCode), DwmcEntity::getOrgId, mineCode));
        if (dwmcEntities.isEmpty()) {
            return new ArrayList<>();
        }
        return dwmcEntities;
    }

    /**
     * 根据煤矿名称获取当天煤矿带班和值班记录
     * @param mineName
     * @return
     */
    @Override
    public List<ShiftManagementPo> getFineDataBeOnWatchListBymineName(String mineName) {

        //获取当天带值班记录列表
        List<ShiftManagementPo> list = shiftManagementMapper.getFineDataBeOnWatchListBymineName(mineName);
        if (list.isEmpty()) {
            return new ArrayList<>();
        }

        return list;
    }

    /**
     * 根据煤矿名称获取煤矿班次记录
     * @param mineName
     * @return
     */
    @Override
    public List<InsertShiftManage1Po> getFineDataClassListBymineName(String mineName) {
        List<InsertShiftManage1Po> insertShiftManage1Pos = insertShiftManage1Mapper.selectList(new LambdaQueryWrapper<InsertShiftManage1Po>()
                .eq(StringUtils.isNotBlank(mineName), InsertShiftManage1Po::getDw, mineName));
        if (insertShiftManage1Pos.isEmpty()) {
            return new ArrayList<>();
        }
        return insertShiftManage1Pos
                ;
    }
}
